from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import time



driver =webdriver.Chrome()
driver.get('https://sahitest.com/demo/selectTest.htm')
s1 =driver.find_element(By.ID,'s1')
select =Select(s1)

select.select_by_index(1)
time.sleep(2)
select.select_by_value('49')
time.sleep(2)
select.select_by_visible_text("Mail")
time.sleep(2)

# driver.quit()


# 第二种
# driver =webdriver.Chrome()
# driver.get('https://sahitest.com/demo/selectTest.htm')
# time.sleep(2)
# s2 =driver.find_element(By.XPATH,'//select[@id="s1"]/option[2]').click()
# time.sleep(2)
# s3 =driver.find_element(By.XPATH,'//select[@id="s1"]/option[3]').click()
#
#
# driver.quit()